package com.dq.domain.sys.user;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.goods.Goods;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/**
 * @author liuhui
 * @date 2019/9/17 0017 09:15:49
 */
@Data
@Entity
@ApiModel("我的收藏")
public class UserCollection extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("用户对象")
    @ManyToOne
    protected SysUser user;

    @ManyToOne
    @ApiModelProperty("商品对象")
    protected Goods goods;


    @Data
    @ApiModel(value = "收藏视图")
    public static class Vo implements VO {

    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();

        return vo;
    }
    @Data
    @ApiModel("收藏列表视图")
    public static class MyCollection{
        @ApiModelProperty("商品id")
        protected Long goodsId;
        @ApiModelProperty(value = "列表图")
        protected String listImgUrl;
        @ApiModelProperty("商品标题")
        protected String goodsName;
        @ApiModelProperty("商品详情描述")
        protected String goodsDescription;
        @ApiModelProperty(value = "市场价")
        protected BigDecimal originalPrice;
        @ApiModelProperty(value = "购买价格")
        protected BigDecimal price;
        @ApiModelProperty("收藏时间")
        protected String createTime;
    }

    public MyCollection tomyCollection(){
        MyCollection vo = new MyCollection();
        vo.listImgUrl = this.goods.getListImgUrl();
        vo.goodsName = this.goods.getGoodsName();
        vo.goodsDescription = this.goods.getGoodsDescription();
        vo.originalPrice = this.goods.getOriginalPrice();
        vo.price = this.goods.getPrice();
        vo.createTime = fmt(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.goodsId = this.goods.getId();
        return vo;
    }
}
